<?php
session_start();
require_once('Conection_DataBase.php');
mysql_select_db($database_jssue, $jssue);

$desde = $_GET["fechDesde"];
$hasta = $_GET["fechHasta"];
$fechas = $_GET["fechas"];
$tipoFecha=$_GET["tipoFecha"];
if ($fechas==1) {
    $Querry_recordSet = "select * from cllg_cheque where STATUS in(0,2)";
    $rsRechazados = mysql_query($Querry_recordSet, $jssue) or die(mysql_error());

    $Querry_recordSet = "select * from cllg_cheque where STATUS in(0)";
    $rsNoRecuperados = mysql_query($Querry_recordSet, $jssue) or die(mysql_error());

    $Querry_recordSet = "select * from cllg_cheque where STATUS in(2)";
    $rsRecuperados = mysql_query($Querry_recordSet, $jssue) or die(mysql_error());
}else{
	$campoFecha=$tipoFecha==1?"FECHA_RECHAZO":"FECHA_REPOSICION";
    $Querry_recordSet = "select * from cllg_cheque where $campoFecha BETWEEN '$desde' and '$hasta' AND STATUS in(0,2)";
    $rsRechazados = mysql_query($Querry_recordSet, $jssue) or die(mysql_error());

    $Querry_recordSet = "select * from cllg_cheque where $campoFecha BETWEEN '$desde' and '$hasta' AND STATUS in(0)";
    $rsNoRecuperados = mysql_query($Querry_recordSet, $jssue) or die(mysql_error());

    $Querry_recordSet = "select * from cllg_cheque where $campoFecha BETWEEN '$desde' and '$hasta' AND STATUS in(2)";
    $rsRecuperados = mysql_query($Querry_recordSet, $jssue) or die(mysql_error());
}
$Fec = date('d-m-Y');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Cheques</title>
        <link href="css/print.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="../../../js/prototype.js">
</script>
    </head>

    <body>
        <div id="wrap" >
		<div id="content">
                <h2>Reporte Cheques  del <?php echo date("m-d-Y",strtotime(date("Y-m-d",strtotime($desde))));?> 
          Al <?php echo date("m-d-Y",strtotime(date("Y-m-d",strtotime($hasta))));?></h2>
                <table width="296">
                    <tr>
                        <td id="noprint">  <div id="no">
    <form id="form1" name="form1" method="post" action="">
      <input type="button" name="printer" id="printer" value="Imprimir" onclick="$('no').hide();window.print();alert('Impresion Lista!');$('no').show();" />
        </form>
  </div>
                        </td>
                    </tr>
                </table>
                <h3>Rechazados</h3>
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <th width="19%" align="left">Numero</th>
                        <th width="19%" align="left">Fecha</th>
                        <th width="13%" align="left" >Monto</th>
                        <th width="13%" align="left">Banco</th>
                        <th width="18%" align="left">Fecha Rechazo</th>
                        <th width="18%" align="left">Concepto</th>
                    </tr>
                    <?php
                    $sum1=0;
                    while ($rowRecordset=mysql_fetch_assoc($rsRechazados)) {
                        $sum1+=$rowRecordset["MONTO"];
                        ?>
                        <tr>
                            <td><?php echo $rowRecordset['NUMERO'];?></td>
                            <td><?php echo $rowRecordset['FECHA'];?></td>
                            <td><?php echo number_format($rowRecordset['MONTO'],2);?></td>
                            <td><?php echo $rowRecordset['BANCO'];?></td>
                            <td><?php echo $rowRecordset['FECHA_COBRO'];?></td>
                            <td><?php echo $rowRecordset['CONCEPTO_RECHAZO'];?></td>
                        </tr>
                        <?php
                    }
                    ?>
                    <tfoot>
                        <tr>
                            <td colspan="2" align="left">Total:
                            </td>
                            <td><?php echo number_format($sum1,2);?></td>
                            <td colspan="3">&nbsp;</td>

                        </tr>
                    </tfoot>
                </table>
                &nbsp;
                <h3>Rechazados No Recuperados</h3>
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <th width="19%" align="left">Numero</th>
                        <th width="19%" align="left">Fecha</th>
                        <th width="13%" align="left" >Monto</th>
                        <th width="13%" align="left">Banco</th>
                        <th width="18%" align="left">Fecha Rechazo</th>
                        <th width="18%" align="left">Concepto Rechazo</th>
                    </tr>
                    <?php
                    $sum2=0;
                    while ($rowRecordset=mysql_fetch_assoc($rsNoRecuperados)) {
                        $sum2+=$rowRecordset["MONTO"];
                        ?>

                    <tr>
                        <td><?php echo $rowRecordset['NUMERO'];?></td>
                        <td><?php echo $rowRecordset['FECHA'];?></td>
                        <td><?php echo number_format($rowRecordset['MONTO'],2);?></td>
                        <td><?php echo $rowRecordset['BANCO'];?></td>
                        <td><?php echo $rowRecordset['FECHA_RECHAZO'];?></td>
                        <td><?php echo $rowRecordset['CONCEPTO_RECHAZO'];?></td>
                    </tr>
                    <?php }?>
                    <tfoot>
                        <tr>
                            <td colspan="2" align="left">Total:
                            </td>
                            <td><?php echo number_format($sum2,2);?></td>
                            <td colspan="3">&nbsp;</td>

                        </tr>
                    </tfoot>
                </table>
                &nbsp;
                <h3>Rechazados Recuperados</h3>
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <th width="19%" align="left">Numero</th>
                        <th width="19%" align="left">Fecha</th>
                        <th width="13%" align="left" >Monto</th>
                        <th width="13%" align="left">Banco</th>
                        <th width="18%" align="left">Fecha Repocisión</th>
                        <th width="18%" align="left">Concepto Reposición</th>
                    </tr>
                    <?php
                    $sum3=0;
                    while ($rowRecordset=mysql_fetch_assoc($rsRecuperados)) {
                        $sum3+=$rowRecordset["MONTO"];
                        ?>

                    <tr>
                        <td><?php echo $rowRecordset['NUMERO'];?></td>
                        <td><?php echo $rowRecordset['FECHA'];?></td>
                        <td><?php echo number_format($rowRecordset['MONTO'],2);?></td>
                        <td><?php echo $rowRecordset['BANCO'];?></td>
                        <td><?php echo $rowRecordset['FECHA_REPOSICION'];?></td>
                        <td><?php echo $rowRecordset['CONCEPTO_REPOSICION'];?></td>
                    </tr>
                    <?php }?>
                    <tfoot>
                        <tr>
                            <td colspan="2" align="left">Total:
                            </td>
                            <td><?php echo number_format($sum3,2);?></td>
                            <td colspan="3">&nbsp;</td>
                        </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </body>
</html>